package com.cda.mall.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cda.mall.entity.UserAddr;
import com.cda.mall.dao.UserAddrMapper;
import com.cda.mall.service.IUserAddrService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cda.mall.vo.ResStatus;
import com.cda.mall.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 用户地址  服务实现类
 * </p>
 *
 * @author cda
 * @since 2021-11-13
 */
@Service
public class UserAddrServiceImpl extends ServiceImpl<UserAddrMapper, UserAddr> implements IUserAddrService {

    @Autowired
    private UserAddrMapper userAddrMapper;


    @Transactional(propagation = Propagation.SUPPORTS)
    public ResultVO listAddrsByUid(int userId) {
        QueryWrapper<UserAddr> wrapper = new QueryWrapper();
        wrapper.eq("user_id",userId);
        wrapper.eq("status",1);
        List<UserAddr> list = userAddrMapper.selectList(wrapper);
        return new ResultVO(ResStatus.OK,"success",list);
    }
}
